Skip to content

fix: reject --save-retain-interval, which deletes every previous checkpoint - #2547

Open
FeiyangP wants to merge 1 commit into
THUDM:mainfrom
FeiyangP:fix/reject-save-retain-interval
Open

FeiyangP wants to merge 1 commit into
THUDM:mainfrom
FeiyangP:fix/reject-save-retain-interval

Conversation

@FeiyangP

Copy link
Copy Markdown

Problem

Fixes #2532.

slime forwards Megatron's --save-retain-interval unchanged, but it saves checkpoint rollout_id (0-based): with --save-interval N the saved iterations are N-1, 2N-1, .... Megatron's iter_finalize_fn deletes the previous checkpoint whenever prev_iteration % save_retain_interval != 0, and none of slime's iterations is ever a multiple of the retain interval. So each save deletes the one before it, and only the latest checkpoint survives: the opposite of what the option is for. The issue has the full code path and a 2-GPU reproduction, including an iter_0000003 left half-deleted when the job exits.

Runs that don't set --save-retain-interval are not affected, because Megatron then deletes nothing.

Change

slime_validate_args now raises a ValueError when --save-retain-interval is set. The message explains the numbering mismatch and links the issue. This is the first option proposed in #2532. It turns silent checkpoint loss into an error at startup and leaves the checkpoint numbering alone, which actor.py, slime/data/checkpoint.py, the queue data source and --ckpt-step / --ref-ckpt-step depend on.

The check uses getattr(args, "save_retain_interval", None), so a Megatron parser that has no such option is unaffected.

Doing retention in slime by step count (the issue's second option) would need careful handling of async saves and of shutdown. I left that for a follow-up if maintainers want it. The open "keep the last N checkpoints" PRs (#1798, #1914, #2290) don't touch --save-retain-interval, so they don't overlap with this change.

Tests

  • New test_slime_validate_args_rejects_save_retain_interval: fails on main (DID NOT RAISE ValueError) and passes with the fix.
  • New test_slime_validate_args_accepts_unset_save_retain_interval: passes before and after.
  • pytest tests/test_megatron_argument_validation.py (CPU venv: torch, numpy, ray, pyyaml): 67 passed, 8 failed after the change vs. 65 passed, 8 failed on main. The same 8 tests fail on both, from optional dependencies missing in my environment, so the change introduces no new failures.
  • pre-commit run --files on both changed files: ruff, autoflake, isort and black all pass.

I didn't run a GPU training job. The change only adds an argument check.

Duplicate check

I searched PRs for save-retain-interval, save_retain_interval and 2532 and found none.

AI assistance: this change was prepared with the help of an AI coding assistant. I reviewed the diff and the tests.

…kpoint

slime saves checkpoint rollout_id (0-based), so with --save-interval N the
iterations are N-1, 2N-1, ...; Megatron's retention deletes every previous
checkpoint that is not a multiple of --save-retain-interval, so forwarding
the option keeps only the latest checkpoint. Fail at argument validation
instead of silently deleting checkpoints.

Fixes THUDM#2532

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] --save-retain-interval deletes every previous checkpoint: slime passes the 0-based rollout_id as Megatron's iteration

1 participant